package com.sunwayhorizo.health.hl7.rim;

import com.sunwayhorizo.health.hl7.common.*;
import com.sunwayhorizo.health.hl7.datatypes.*;
import com.sunwayhorizo.health.hl7.factories.*;
import com.sunwayhorizo.health.hl7.persistent.*;
import static com.sunwayhorizo.health.hl7.vocabulary.RoleCdSetCode.*;
import java.io.*;
import javax.persistence.*;

@Entity
@DiscriminatorValue("PAT")
@Inheritance
public class Patient extends Role implements Serializable
{
    /**
	 * 
	 */
    protected static final long serialVersionUID = 1L;

    public Patient()
    {
    }


    public Patient(ReferenceModifier referencemodifier)
    {
        super(referencemodifier);
    }


    public void setVeryImportantPersonCode(CE ce)
    {
        if (null != ce && ce.codeSystemEnName() != null && ce.codeName() != null)
        {
            setRimCoreRoleCdSets(ce, VIPCODE);
        }
        else
        {
            this.setPtVipCodeEtsId(ce.code().toString());
        }
    }


    public CE getVeryImportantPersonCode() throws Hl7Exception
    {
        if (this.getPtVipCodeEtsId().equals(VIPCODE.toString()))
        {
            for (RimCoreRoleCdSets roleCdSets : this.getRoleCdSetsList())
            {
                if (this.getPtVipCodeEtsId().equals(roleCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(roleCdSets);
                }
            }
        }
        else
        {
            return DataTypeUtil.getCE(this.getPtVipCodeEtsId());
        }
        return null;
    }

    // Patient
    @Column(name = "PT_VIP_CODE_ETS_ID")
    protected String ptVipCodeEtsId = VIPCODE.toString();


    protected String getPtVipCodeEtsId()
    {
        return ptVipCodeEtsId;
    }


    protected void setPtVipCodeEtsId(String ptVipCodeEtsId)
    {
        this.ptVipCodeEtsId = ptVipCodeEtsId;
    }

}
